<div class="{{$viewClass['form-group']}} {!! !$errors->has($errorKey) ? '' : 'has-error' !!}">

    <label for="{{$id['lat']}}" class="{{$viewClass['label']}} control-label">{{$label}}</label>

    <div class="{{$viewClass['field']}}">

        @include('admin::form.error')
        要查询的地址：<input id="text_" type="text" class="form-inline" value="北京" style="margin-right:100px;width: 100px"/>
        查询结果(经纬度)：<input id="result_" type="text"  class="form-inline"/>
        <input type="button" value="查询" onclick="searchByStationName()"/>
        <div id="map_{{$id['lat'].$id['lng']}}" style="width: 100%;height: 300px"></div>
        <input type="hidden" id="{{$id['lat']}}" name="{{$name['lat']}}" value="{{ old($column['lat'], $value['lat']) }}" {!! $attributes !!} />
        <input type="hidden" id="{{$id['lng']}}" name="{{$name['lng']}}" value="{{ old($column['lng'], $value['lng']) }}" {!! $attributes !!} />
        @include('admin::form.help-block')

    </div>
</div>
<script src="http://api.map.baidu.com/api?v=2.0&ak=ziq74kGuGFe7HASYuRm6ipXg"></script>
<script>


        var lat = $('#{{$id['lat']}}');
        var lng = $('#{{$id['lng']}}');
        var map = new BMap.Map("map_{{$id['lat']}}{{$id['lng']}}");
        if (lat.val()) {
            map.centerAndZoom(new BMap.Point(lng.val(), lat.val()), 12);
            Marker( lat.val(),lng.val(),);
        } else {
            map.centerAndZoom(new BMap.Point(116.404, 39.915), 12);
            Marker( 39.915,116.404);
        }
        map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
        map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
        map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
        map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件
        map.addControl(new BMap.OverviewMapControl({isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT}));   //右下角，打开
        function searchByStationName() {
            //百度地图API功能
            var localSearch = new BMap.LocalSearch(map);
            localSearch.enableAutoViewport();
            var keyword = document.getElementById("text_").value;
            localSearch.setSearchCompleteCallback(function (searchResult) {
                var poi = searchResult.getPoi(0);
                document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat; //获取经度和纬度，将结果显示在文本框中
                map.centerAndZoom(poi.point, 13);
                Marker(poi.point.lat, poi.point.lng);
            });
            localSearch.search(keyword);
        }
       function showInfo(e) {

                document.getElementById("result_").value = e.point.lng + "," + e.point.lat
                Marker(e.point.lat, e.point.lng);
            }

            function Marker(lat, lng, is_delete = 0) {
                $('#{{$id['lat']}}').val(lat);
                $('#{{$id['lng']}}').val(lng);

                var pt = new BMap.Point(lng, lat, 12);
                var allOverlay = map.getOverlays();
                //删除标志物
                for (var i = 0; i < allOverlay.length; i++) {
                    map.removeOverlay(allOverlay[i]);
                }
                // var myIcon = new BMap.Icon("http://lbsyun.baidu.com/jsdemo/img/fox.gif", new BMap.Size(300,157));
                var marker = new BMap.Marker(pt);  // 创建标注

                map.addOverlay(marker);
                marker.setAnimation(BMAP_ANIMATION_BOUNCE);
            }

            map.addEventListener("click", showInfo);




</script>